home *** CD-ROM | disk | FTP | other *** search
- unit Main;
- {.$I DRLib.inc}
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- DBTables, StdCtrls, ExtCtrls, DREng, DRBase;
- Const
- TEXT_RETURN = Char(#13) + Char(#10);
- type
- TFormMain = class(TForm)
- Image2: TImage;
- MemoShow: TMemo;
- BPrint: TButton;
- BPreview: TButton;
- DReport: TDuckReport;
- RGType: TRadioGroup;
- procedure FormCreate(Sender: TObject);
- procedure BPrintClick(Sender: TObject);
- procedure BPreviewClick(Sender: TObject);
- private
- Procedure ShowErrorAlias;
- Procedure WMCustom (Var Message: TMessage); Message WM_USER + 100;
- Procedure Customer (bPrint: Boolean);
- Procedure Order (bPrint: Boolean);
- Procedure Invoice (bPrint: Boolean);
- Procedure MailLabel (bPrint: Boolean);
- Procedure Envelope (bPrint: Boolean);
- Procedure BioLife (bPrint: Boolean);
- Procedure Barcode (bPrint: Boolean);
- Procedure Lookup (bPrint: Boolean);
- Procedure RichBioLife (bPrint: Boolean);
- Procedure SummaryPayment (bPrint: Boolean);
- Procedure SummaryShipVIA (bPrint: Boolean);
- Procedure FormulaPayment (bPrint: Boolean);
- Procedure FormulaShipVIA (bPrint: Boolean);
- Procedure ChartPayment (bPrint: Boolean);
- Procedure ChartShipVIA (bPrint: Boolean);
- Procedure ChartSummary (bPrint: Boolean);
- Procedure ChartMonth (bPrint: Boolean);
- Procedure ChartYear (bPrint: Boolean);
- public
- end;
-
- var
- FormMain: TFormMain;
-
- implementation
-
- uses FOrder, FYear;
-
- {$R *.DFM}
- Procedure TFormMain.FormCreate(Sender: TObject);
- Var
- St: String;
- StAlias: String;
- Database: TDatabase;
- List: TStringList;
- iPos: Integer;
- Begin
- St := 'Duck Report Version ' + Display_VERSION;
- {$IFDEF DRVERSION_FREE}
- St := St + ' (Freeware)';
- {$ELSE}
- {$IFDEF DRVERSION_REGISTER}
- St := St + ' (Register)';
- {$ELSE} { DRVERSION_FULL }
- St := St + ' (License)';
- {$ENDIF}
- {$ENDIF}
- MemoShow.Lines.Insert (0, St);
- MemoShow.Lines.Insert (1, 'Copyright (c) 1998');
-
-
- StAlias := 'DRDEMOS';
- St := Application.ExeName;
- St := ExtractFileDir (St);
- St := UpperCase (St);
- DReport.Directory := St;
- List := TStringList.Create;
- Session.GetAliasNames (List);
- iPos := List.IndexOf (StAlias);
- if iPos <= 0 Then
- Begin
- iPos := Pos ('\DEMOS\DEMO1', St);
- if iPos <= 0 Then
- Begin
- ShowErrorAlias;
- End;
- Delete (St, iPos, Length (St) - iPos + 1);
- St := St + '\DATA';
- List.Clear;
- List.Add ('PATH =' + St);
- List.Add ('DEFAULT DRIVER =PARADOX');
- Try
- Session.AddAlias (StAlias, 'PARADOX', List);
- Finally
- Session.SaveConfigFile;
- End;
- End;
- List.Free;
- End;
- Procedure TFormMain.ShowErrorAlias;
- Begin
- MessageBeep (0);
- MessageDlg ('Please Apppend BDE Alias DRDEMOS.' + TEXT_RETURN +
- 'And Setup Path to <Duck Report Dir.>\Data',
- mtError, [mbOK],0);
- PostMessage (Self.Handle, WM_USER + 100, 0, 0);
- End;
- Procedure TFormMain.WMCustom (Var Message: TMessage);
- Begin
- Close;
- End;
- Procedure TFormMain.BPrintClick(Sender: TObject);
- Begin
- Case RGType.ItemIndex of
- 0: Customer(TRUE);
- 1: Order(TRUE);
- 2: Invoice(TRUE);
- 3: MailLabel(TRUE);
- 4: Envelope(TRUE);
- 5: BioLife(TRUE);
- 6: Barcode(TRUE);
- 7: Lookup(TRUE);
- 8: RichBioLife(TRUE);
- 9: SummaryPayment(TRUE);
- 10: SummaryShipVIA(TRUE);
- 11: FormulaPayment(TRUE);
- 12: FormulaShipVIA(TRUE);
- 13: ChartPayment(TRUE);
- 14: ChartShipVIA(TRUE);
- 15: ChartSummary(TRUE);
- 16: ChartMonth(TRUE);
- 17: ChartYear(TRUE);
- End;
- End;
- Procedure TFormMain.BPreviewClick(Sender: TObject);
- Begin
- Case RGType.ItemIndex of
- 0: Customer(FALSE);
- 1: Order(FALSE);
- 2: Invoice(FALSE);
- 3: MailLabel(FALSE);
- 4: Envelope(FALSE);
- 5: BioLife(FALSE);
- 6: Barcode(FALSE);
- 7: Lookup(FALSE);
- 8: RichBioLife(FALSE);
- 9: SummaryPayment(FALSE);
- 10: SummaryShipVIA(FALSE);
- 11: FormulaPayment(FALSE);
- 12: FormulaShipVIA(FALSE);
- 13: ChartPayment(FALSE);
- 14: ChartShipVIA(FALSE);
- 15: ChartSummary(FALSE);
- 16: ChartMonth(FALSE);
- 17: ChartYear(FALSE);
- End;
- End;
- Procedure TFormMain.Customer (bPrint: Boolean);
- Begin
- DReport.Filter := '';
- DReport.FileName := 'Customer.DRP';
- DReport.OpenFile;
- DReport.OpenDB;
- if bPrint Then
- DReport.Print
- Else
- DReport.Preview;
- End;
- Procedure TFormMain.Order (bPrint: Boolean);
- Begin
- DReport.Filter := '';
- DReport.FileName := 'Order.DRP';
- DReport.OpenFile;
- DReport.OpenDB;
- if bPrint Then
- DReport.Print
- Else
- DReport.Preview;
- End;
- Procedure TFormMain.Invoice (bPrint: Boolean);
- Var
- dOrder: Double;
- Begin
- dOrder := 0;
- FormOrderNo := TFormOrderNo.Create (Self);
- FormOrderNo.ShowModal;
- if FormOrderNo.ModalResult = mrOK Then
- Begin
- dOrder := FormOrderNo.dOrder;
- End;
- FormOrderNo.Free;
-
- if dOrder = 0 Then Exit;
-
- DReport.Filter := '';
- DReport.FileName := 'Invoice.DRP';
- DReport.OpenFile;
- DReport.Variables.ByName['OrderNo'].AsDouble := dOrder;
- DReport.OpenDB;
- if bPrint Then
- DReport.Print
- Else
- DReport.Preview;
- End;
- Procedure TFormMain.MailLabel (bPrint: Boolean);
- Begin
- DReport.Filter := '';
- DReport.FileName := 'Label.DRP';
- DReport.OpenFile;
- DReport.OpenDB;
- if bPrint Then
- DReport.Print
- Else
- DReport.Preview;
- End;
- Procedure TFormMain.Envelope (bPrint: Boolean);
- Begin
- DReport.Filter := '';
- DReport.FileName := 'Envelope.DRP';
- DReport.OpenFile;
- DReport.OpenDB;
- if bPrint Then
- DReport.Print
- Else
- DReport.Preview;
- End;
- Procedure TFormMain.BioLife (bPrint: Boolean);
- Begin
- DReport.Filter := '';
- DReport.FileName := 'BioLife.DRP';
- DReport.OpenFile;
- DReport.OpenDB;
- if bPrint Then
- DReport.Print
- Else
- DReport.Preview;
- End;
- Procedure TFormMain.Barcode (bPrint: Boolean);
- Begin
- DReport.Filter := '';
- DReport.FileName := 'Barcode.DRP';
- DReport.OpenFile;
- DReport.OpenDB;
- if bPrint Then
- DReport.Print
- Else
- DReport.Preview;
- End;
- Procedure TFormMain.Lookup (bPrint: Boolean);
- Begin
- DReport.Filter := '';
- DReport.FileName := 'Lookup.DRP';
- DReport.OpenFile;
- DReport.OpenDB;
- if bPrint Then
- DReport.Print
- Else
- DReport.Preview;
- End;
- Procedure TFormMain.RichBioLife (bPrint: Boolean);
- Begin
- DReport.Filter := '';
- DReport.FileName := 'RichBioLife.DRP';
- DReport.OpenFile;
- DReport.OpenDB;
- if bPrint Then
- DReport.Print
- Else
- DReport.Preview;
- End;
- Procedure TFormMain.SummaryPayment (bPrint: Boolean);
- Var
- iYear: Integer;
- Begin
- iYear := 0;
- FormYear := TFormYear.Create (Self);
- FormYear.ShowModal;
- if FormYear.ModalResult = mrOK Then
- iYear := FormYear.iYear;
- FormYear.Free;
- if iYear = 0 Then Exit;
- DReport.Filter := '';
- DReport.FileName := 'SummaryPayment.DRP';
- DReport.OpenFile;
- DReport.Variables.ByName['StartDate'].AsDateTime := EncodeDate (iYear, 01, 01);
- DReport.Variables.ByName['EndDate'].AsDateTime := EncodeDate (iYear, 12, 31);
- DReport.OpenDB;
- if bPrint Then
- DReport.Print
- Else
- DReport.Preview;
- End;
- Procedure TFormMain.SummaryShipVIA (bPrint: Boolean);
- Begin
- DReport.Filter := '';
- DReport.FileName := 'SummaryShipVIA.drp';
- DReport.OpenFile;
- DReport.OpenDB;
- if bPrint Then
- DReport.Print
- Else
- DReport.Preview;
- End;
- Procedure TFormMain.FormulaPayment (bPrint: Boolean);
- Var
- iYear: Integer;
- Begin
- iYear := 0;
- FormYear := TFormYear.Create (Self);
- FormYear.ShowModal;
- if FormYear.ModalResult = mrOK Then
- iYear := FormYear.iYear;
- FormYear.Free;
- if iYear = 0 Then Exit;
- DReport.Filter := '';
- DReport.FileName := 'FormulaPayment.DRP';
- DReport.OpenFile;
- DReport.Variables.ByName['StartDate'].AsDateTime := EncodeDate (iYear, 01, 01);
- DReport.Variables.ByName['EndDate'].AsDateTime := EncodeDate (iYear, 12, 31);
- DReport.OpenDB;
- if bPrint Then
- DReport.Print
- Else
- DReport.Preview;
- End;
- Procedure TFormMain.FormulaShipVIA (bPrint: Boolean);
- Begin
- DReport.Filter := '';
- DReport.FileName := 'FormulaShipVIA.drp';
- DReport.OpenFile;
- DReport.OpenDB;
- if bPrint Then
- DReport.Print
- Else
- DReport.Preview;
- End;
- Procedure TFormMain.ChartPayment (bPrint: Boolean);
- Var
- iYear: Integer;
- Begin
- iYear := 0;
- FormYear := TFormYear.Create (Self);
- FormYear.ShowModal;
- if FormYear.ModalResult = mrOK Then
- iYear := FormYear.iYear;
- FormYear.Free;
- if iYear = 0 Then Exit;
- DReport.Filter := '';
- DReport.FileName := 'ChartPayment.DRP';
- DReport.OpenFile;
- DReport.Variables.ByName['StartDate'].AsDateTime := EncodeDate (iYear, 01, 01);
- DReport.Variables.ByName['EndDate'].AsDateTime := EncodeDate (iYear, 12, 31);
- DReport.OpenDB;
- if bPrint Then
- DReport.Print
- Else
- DReport.Preview;
- End;
- Procedure TFormMain.ChartShipVIA (bPrint: Boolean);
- Begin
- DReport.Filter := '';
- DReport.FileName := 'ChartShipVIA.drp';
- DReport.OpenFile;
- DReport.OpenDB;
- if bPrint Then
- DReport.Print
- Else
- DReport.Preview;
- End;
- Procedure TFormMain.ChartSummary (bPrint: Boolean);
- Begin
- DReport.Filter := '';
- DReport.FileName := 'ChartSummary.drp';
- DReport.OpenFile;
- DReport.OpenDB;
- if bPrint Then
- DReport.Print
- Else
- DReport.Preview;
- End;
- Procedure TFormMain.ChartMonth (bPrint: Boolean);
- Begin
- DReport.Filter := '';
- DReport.FileName := 'ChartMonth.drp';
- DReport.OpenFile;
- DReport.OpenDB;
- if bPrint Then
- DReport.Print
- Else
- DReport.Preview;
- End;
- Procedure TFormMain.ChartYear (bPrint: Boolean);
- Begin
- DReport.Filter := '';
- DReport.FileName := 'ChartYear.drp';
- DReport.OpenFile;
- DReport.OpenDB;
- if bPrint Then
- DReport.Print
- Else
- DReport.Preview;
- End;
- End.
-